<?php
namespace Pay\Service;
use Plugins\function\MemcacheLock;

class PayService
{

    public  function  giveOutMoney($userId,$money,$renwuId,$remake="任务完成",$type="renwu"){
        //防止高并发
        include_once  "plugins/functions/MemcacheLock.php";
        $cachelock =$this->cachKey."_balancePay_".$userId;
        $MemcacheLock = new MemcacheLock();
        $lock = $MemcacheLock->addLock($cachelock, 120);
        if (!$lock) {
            return  ["code"=>0,"msg"=>"出现错误"];
        }
        $res= setUserMoneyRepot($userId,$money,$type,$remake,1,$renwuId);
        if(empty($res)){
            $MemcacheLock->releaseLock($cachelock);
            return  ["code"=>0,"msg"=>"出现错误"];
        }
        $MemcacheLock->releaseLock($cachelock);
        return  ["code"=>1,"msg"=>"支付成功"];

    }
}